<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>客户申请列表</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">

    <script src="/js/axios.min.js"></script>
    <script src="/js/vue.js"></script>
    <script src="/js/qs.min.js"></script>
    <script src="/js/jquery.js"></script>

    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<body>
<div id="app">
    <template>
        <div class="block">
            <span class="demonstration">请选择：</span>
            <el-date-picker
                    value-format="yyyy-MM-dd"
                    v-model="startTime"
                    type="date"
                    placeholder="选择日期">
            </el-date-picker>

            <span class="demonstration">至</span>
            <el-date-picker
                    value-format="yyyy-MM-dd"
                    v-model="endTime"
                    type="date"
                    placeholder="选择日期">
            </el-date-picker>
            <el-button type="primary" icon="el-icon-search" @click="loadTPars">查询</el-button>
        </div>

    </template>
    <template>
        <el-table style="width: 100%"
                  :data="tPars"
                  ref="tParTable">
            <el-table-column label="id" width="80">
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.id }}</span>
                </template>
            </el-table-column>

            <el-table-column label="公司名称" width="180">
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.scompany.companyName }}</span>
                </template>
            </el-table-column>

            <el-table-column label="公司区域" width="180">
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.scompany.companyAddress }}</span>
                </template>
            </el-table-column>

            <el-table-column label="主要经营" width="100">
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.scompany.companyScope }}</span>
                </template>
            </el-table-column>

            <el-table-column label="申请状态" width="80">
                <template slot-scope="scope">
                    <div v-if="scope.row.tparStatus == '已申请'" style="background-color:yellow;width: 60px;height: 22px;color: black"><span style="margin-left: 10px">{{ scope.row.tparStatus }}</span></div>
                    <div v-if="scope.row.tparStatus == '已拒绝'" style="background-color:red;width: 60px;height: 22px;color: black"><span style="margin-left: 10px">{{ scope.row.tparStatus }}</span></div>
                    <div v-if="scope.row.tparStatus == '已同意'" style="background-color:green;width: 60px;height: 22px;color: black"><span style="margin-left: 10px">{{ scope.row.tparStatus }}</span></div>
                </template>
            </el-table-column>

            <el-table-column label="申请时间" width="180">
                <template slot-scope="scope">
                    <span style="margin-left: 10px">{{ scope.row.tparTime }}</span>
                </template>
            </el-table-column>
            <el-table-column label="备注" width="180">
                <template slot-scope="scope">
                    <span style="margin-left: 10px;">{{ scope.row.tparDesc }}</span>
                </template>
            </el-table-column>


            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button size="mini" icon="el-icon-edit" @click="handleEdit(scope.$index, scope.row)">查看</el-button>
                </template>
            </el-table-column>
        </el-table>

        <div class="block" style="margin-top: 10px;">
            <el-pagination @size-change="handleSizeChange"
                           @current-change="handleCurrentChange"
                           :current-page="currentPage"
                           :page-sizes="page_size"
                           :page-size="4"
                           layout="total, sizes, prev, pager, next, jumper"
                           :total="count"
                           :background="back">
            </el-pagination>
        </div>
    </template>
    <el-dialog title="合作审核" :visible.sync="dialogFormVisible" width="900px" height="800px" @close="closeDialog()">
        <template>
            <span>申请成为：</span>
            <el-radio disabled v-model="radio" label="1">客户</el-radio>
            <el-radio disabled v-model="radio" label="0">供应商</el-radio><br>
            <span>企业产品列表</span><br>
            <el-table style="width: 100%"
                      :data="products">
                <el-table-column label="id" width="80">
                    <template slot-scope="scope">
                        <span style="margin-left: 10px">{{ scope.row.id }}</span>
                    </template>
                </el-table-column>

                <el-table-column label="产品名称" width="180">
                    <template slot-scope="scope">
                        <span style="margin-left: 10px">{{ scope.row.pname }}</span>
                    </template>
                </el-table-column>

                <el-table-column label="产品数量" width="180">
                    <template slot-scope="scope">
                        <span style="margin-left: 10px">{{ scope.row.pnumber }}</span>
                    </template>
                </el-table-column>

                <el-table-column label="产品价格" width="180">
                    <template slot-scope="scope">
                        <span style="margin-left: 10px">{{ scope.row.pprice }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="企业产品" width="180">
                    <template slot-scope="scope">
                        <span style="margin-left: 10px;">{{ scope.row.penterprise }}</span>
                    </template>
                </el-table-column>

            </el-table>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
            </div>
        </template>
    </el-dialog>
</div>
</body>
<script>


    new Vue({
        el: "#app",
        data(){
            return{
                // 当前页数
                currentPage: 1,
                // 订单总数
                count : 0,
                // 每页的数据
                page_size : [6,3],
                // 当前每页的数据
                pageSize : 6,
                // 分页背景
                back: true,
                tPars: [],
                products:[],
                tPar: {},
                startTime:"",
                endTime:"",
                radio:"",
                dialogFormVisible: false,
                pickerOptions: {
                    disabledDate(time) {
                        return time.getTime() > Date.now();
                    },
                }
            }
        },
        methods:{
            loadTPars(){
                axios.get("/tPars/page/" + this.currentPage + "/" + this.pageSize + "?startTime=" + this.startTime + "&endTime=" + this.endTime)
                    .then(res => {
                        this.tPars = res.data.data;
                        this.count = res.data.count;
                    });
            },
            handleSizeChange(val) {
                this.pageSize = val;
                this.loadTPars();

            },
            handleCurrentChange(val) {
                this.currentPage = val;
                this.loadTPars();
            },
            handleEdit(index, row) {
                this.tPar = row;
                axios.get("/companyProducts?id=" + row.tparComB).then(res =>{
                    this.products = res.data;
                });
                this.radio = this.tPar.tparRel;
                this.dialogFormVisible = true;
            },
            closeDialog() {
                this.tPar = "";
            },
        },
        mounted(){
            this.loadTPars();
        }
    });
</script>
</html>